package com.itheima.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.itheima.common.ResultData;
import com.itheima.domain.UmsResourceCategory;
import com.itheima.manager.UmsResourceCategoryManager;
import com.itheima.service.UmsResourceCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 资源分类表 前端控制器
 * </p>
 *
 * @author zhuguo
 * @since 2022-11-10
 */
@RestController
@RequestMapping("/resourceCategory")
@CrossOrigin(origins = "*")
public class UmsResourceCategoryController {

    @Autowired
    private UmsResourceCategoryManager umsResourceCategoryManager;

    // 查询后台所有资源分类
    @GetMapping("/listAll")
    public ResultData listAll(){
        return umsResourceCategoryManager.listAll();

    }

    // 添加后台资源分类
    @PostMapping("/create")
    public ResultData create(@RequestBody UmsResourceCategory category){
        return umsResourceCategoryManager.create(category);
    }

    // 根据ID删除后台资源
    @PostMapping("/delete/{id}")
    public ResultData deleteCategoryById(@PathVariable Integer id){
       return umsResourceCategoryManager.deleteCategoryById(id);

    }

    // 修改后台资源分类
    @PostMapping("/update/{id}")
    public ResultData updateCategoryById(@PathVariable Integer id, @RequestBody UmsResourceCategory resourceCategory){
       return umsResourceCategoryManager.updateCategoryById(id,resourceCategory);
    }
}

